#ifndef FILE_SYSTEM
#define FILE_SYSTEM

#include <sdk_global.h>

#include <QObject>
#include <QList>
#include <QString>
//#include <json/json.h>
#include <ObjectInspectorItem.h>
#include <QtXML/QDomDocument>
#include <QtXML/QDomElement>
#include <QSharedPointer>
#include <FileSystemObject.h>
QT_BEGIN_NAMESPACE

class QDESIGNER_SDK_EXPORT FileSystem: public QObject
{
    Q_OBJECT
public:

    FileSystem();
    virtual ~FileSystem();

    bool newFile(const QString& file_path);
    bool newFileByDialog();


    void saveFile(const QString& file_path);
    void saveFileByDialog();

    void saveSimulationState();

    void loadFile(const QString& filePath);
    void loadFileByDialog();

    void loadSimulationState();

    void addFileSystemObject(QSharedPointer<FileSystemObject> fileObject);

    void beforeSaveFile();
    void beforeLoadFile();

    void afterLoadFile();

    QString getCurrentProjectDir();
    QString getCurrentFilePath();


protected:
    //Json::Value itemToJsonValue(ObjectInspectorItem* item);
    QDomElement itemToDomElement(QStandardItem* item);
    QDomElement itemToDomElementForSimState(QStandardItem* item);

    QStandardItem* domElementToItem( const QDomElement &domElement, QStandardItem* parentItem);
    QStandardItem* domElementToItemForSimState( const QDomElement &domElement, QStandardItem* parentItem);

    void clearProjectDir();
    bool removeFolderContent(const QString &folderDir);
    void creatModelDataDirInProjectDir();
private:
    QDomDocument* m_domDocument;
    QList<QSharedPointer<FileSystemObject>> m_fileObjectList;
    QString m_currentDir;
    QString m_currentFilePath;
};

QT_END_NAMESPACE

#endif // FILE_SYSTEM
